home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / yelp / xslt / toc2html.xsl < prev    next >
Extensible Markup Language  |  2009-10-15  |  10KB  |  266 lines

  1. <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:yelp="http://www.gnome.org/yelp/ns"
  4.                 xmlns="http://www.w3.org/1999/xhtml"
  5.                 extension-element-prefixes="yelp"
  6.                 version="1.0">
  7.  
  8. <xsl:import href="/usr/share/xml/gnome/xslt/gettext/gettext.xsl"/>
  9.  
  10. <xsl:param name="help_icon"/>
  11. <xsl:param name="help_icon_size"/>
  12.  
  13. <xsl:param name="theme.color.text"/>
  14. <xsl:param name="theme.color.background"/>
  15. <xsl:param name="theme.color.text_light"/>
  16. <xsl:param name="theme.color.link"/>
  17. <xsl:param name="theme.color.link_visited"/>
  18. <xsl:param name="theme.color.gray_background"/>
  19. <xsl:param name="theme.color.gray_border"/>
  20. <xsl:param name="theme.color.blue_background"/>
  21. <xsl:param name="theme.color.blue_border"/>
  22. <xsl:param name="theme.color.red_background"/>
  23. <xsl:param name="theme.color.red_border"/>
  24. <xsl:param name="theme.color.yellow_background"/>
  25. <xsl:param name="theme.color.yellow_border"/>
  26.  
  27. <xsl:template match="toc">
  28.   <xsl:variable name="direction">
  29.     <xsl:call-template name="l10n.direction"/>
  30.   </xsl:variable>
  31.   <xsl:variable name="left">
  32.     <xsl:call-template name="l10n.align.start">
  33.       <xsl:with-param name="direction" select="$direction"/>
  34.     </xsl:call-template>
  35.   </xsl:variable>
  36.   <xsl:variable name="right">
  37.     <xsl:call-template name="l10n.align.end">
  38.       <xsl:with-param name="direction" select="$direction"/>
  39.     </xsl:call-template>
  40.   </xsl:variable>
  41.   <yelp:document href="{@id}">
  42.     <html>
  43.       <head>
  44.         <title>
  45.           <xsl:value-of select="title[1]"/>
  46.         </title>
  47.         <style type="text/css"><xsl:text>
  48.         body {
  49.           margin: 0px;
  50.           padding: 0px;
  51.         }
  52.         h1 {
  53.           font-size: 1.6em;
  54.           margin-bottom: 0.4em;
  55.           margin-top: 12px;
  56.           margin-left: 12px;
  57.           margin-right: 12px;
  58.           padding-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 204px;
  59.           padding-top: 0.2em;
  60.           padding-bottom: 0.2em;
  61.           -moz-border-radius: 6px;
  62.           border: solid 1px </xsl:text>
  63.           <xsl:value-of select="$theme.color.blue_border"/><xsl:text>;
  64.           background-color: </xsl:text>
  65.           <xsl:value-of select="$theme.color.blue_background"/><xsl:text>;
  66.           color: </xsl:text>
  67.           <xsl:value-of select="$theme.color.text"/><xsl:text>;
  68.         }
  69.         h1 img {
  70.           float: </xsl:text><xsl:value-of select="$right"/><xsl:text>;
  71.           margin-</xsl:text><xsl:value-of select="$right"/><xsl:text>: 18px;
  72.         }
  73.         h2 h3 {
  74.           color: </xsl:text><xsl:value-of select="$theme.color.text"/><xsl:text>;
  75.         }
  76.         div[class~="body"] { }
  77.         div[class~="leftbar"] {
  78.           position: absolute;
  79.           top: 4em;
  80.           </xsl:text><xsl:value-of select="$left"/><xsl:text>: 12px;
  81.           width: 192px;
  82.           min-height: 192px;
  83.           text-align: </xsl:text><xsl:value-of select="$left"/><xsl:text>;
  84.           /* padding-top: </xsl:text>
  85.           <xsl:value-of select="$help_icon_size"/><xsl:text>px;
  86.           background-image: url("</xsl:text>
  87.           <xsl:value-of select="$help_icon"/><xsl:text>");
  88.           background-position: </xsl:text>
  89.           <xsl:value-of select="(192 - $help_icon_size) div 2"/><xsl:text>px 0px;
  90.           background-repeat: no-repeat;
  91.           opacity: .3; */
  92.         }
  93.         div[class~="leftbackground"] {
  94.           position: absolute;
  95.           top: 4em;
  96.           </xsl:text><xsl:value-of select="$left"/><xsl:text>: 1px;
  97.           width: 210px;
  98.           min-height: 192px;
  99.           text-align: center;
  100.           padding-top: 0px;
  101.           background-image:url("</xsl:text>
  102.           <xsl:value-of select="$help_icon"/><xsl:text>");
  103.           background-position: </xsl:text>
  104.           <xsl:value-of select="(192 - $help_icon_size) div 2"/><xsl:text>px 0px;
  105.  
  106.           background-repeat: no-repeat;
  107.           opacity: .1;          
  108.         }
  109.         div[class~="rightbar"] {
  110.           margin-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 216px;
  111.           margin-</xsl:text><xsl:value-of select="$right"/><xsl:text>: 12px;
  112.           padding: 1em;
  113.           background-color: </xsl:text><xsl:value-of select="$theme.color.background"/><xsl:text>;
  114.           color: </xsl:text><xsl:value-of select="$theme.color.text"/><xsl:text>;
  115.           -moz-border-radius: 8px;
  116.         }
  117.         ul { margin-left: 0em; padding-left: 0em; }
  118.         li[class~="toclist"] {
  119.           margin-top: 0.3em;
  120.           margin-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0em;
  121.           padding-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0em;
  122.           font-size: 1.2em;
  123.           list-style-type: none;
  124.         }
  125.     li li[class~="toclist"] {
  126.       padding-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0.8em;
  127.       font-size: 0.8em;
  128.         }
  129.     li li li[class~="toclist"] {
  130.       padding-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0.8em;
  131.       font-size: 0.6em;
  132.         }
  133.         li[class~="toc"] {
  134.           margin-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0em;
  135.           font-size: 1.2em;
  136.           padding-top: 0.5em;
  137.           list-style-type: none;
  138.         }
  139.         dl {
  140.           margin-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0em;
  141.           padding-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0em;
  142.         }
  143.         dt { font-size: 1.2em; margin-top: 1em; }
  144.         dd {
  145.           margin-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 1em;
  146.           margin-top: 0.5em;
  147.         }
  148.         a { text-decoration: none; color: </xsl:text><xsl:value-of select="$theme.color.link"/><xsl:text>; }
  149.         a:hover { text-decoration: underline; }
  150.         </xsl:text></style>
  151.       </head>
  152.       <body>
  153.         <div>
  154.           <xsl:if test="$direction = 'ltr' or $direction='rtl'">
  155.             <xsl:attribute name="dir">
  156.               <xsl:value-of select="$direction"/>
  157.             </xsl:attribute>
  158.           </xsl:if>
  159.           <xsl:apply-templates mode="body.mode" select="."/>
  160.         </div>
  161.       </body>
  162.     </html>
  163.   </yelp:document>
  164. </xsl:template>
  165.  
  166. <xsl:template name="print.documents">
  167.   <div class="docs">
  168.     <dl>
  169.       <xsl:for-each select="doc">
  170.         <xsl:sort order="ascending" data-type="number"
  171.           select="normalize-space(@weight)"/>
  172.         <xsl:sort select="normalize-space(title)"/>
  173.         <dt class="doc">
  174.           <a href="{@href}" title="{@href}">
  175.             <xsl:if test="tooltip">
  176.               <xsl:attribute name="title">
  177.                 <xsl:value-of select="tooltip"/>
  178.               </xsl:attribute>
  179.             </xsl:if>
  180.             <xsl:value-of select="title"/>
  181.           </a>
  182.         </dt>
  183.         <dd>
  184.           <xsl:value-of select="description"/>
  185.         </dd>
  186.       </xsl:for-each>
  187.     </dl>
  188.   </div>
  189. </xsl:template>
  190.  
  191. <xsl:template name="print.subsections">
  192.   <div class="tocs">
  193.     <ul>
  194.       <xsl:for-each select="toc[../@id = 'index' or .//doc]">
  195.         <xsl:sort select="number(../@id = 'index') * position()"/>
  196.         <xsl:sort select="normalize-space(title)"/>
  197.         <li class="toc">
  198.           <a href="x-yelp-toc:{@id}">
  199.             <xsl:apply-templates select="title[1]/node()"/>
  200.           </a>
  201.         </li>
  202.       </xsl:for-each>
  203.     </ul>
  204.   </div>
  205. </xsl:template>
  206.  
  207. <xsl:template mode="body.mode" match="toc">
  208.   <div class="leftbackground">
  209.   </div>
  210.   <div class="body">
  211.     <h1>
  212.       <xsl:if test="icon">
  213.         <img src="{icon/@file}"/>
  214.       </xsl:if>
  215.       <xsl:apply-templates select="title"/>
  216.     </h1>
  217.     <div class="rightbar">
  218.       <h3><xsl:apply-templates select="description/node()"/></h3>
  219.       <xsl:choose>
  220.         <!-- if there are documents and subsections, only print documents -->
  221.         <xsl:when test="doc[1] and toc[.//doc[1]]">
  222.           <xsl:call-template name="print.documents"/>
  223.         </xsl:when>
  224.         <!-- if there are documents, print them -->
  225.         <xsl:when test="doc[1]">
  226.           <xsl:call-template name="print.documents"/>
  227.         </xsl:when>
  228.         <!-- Only subsections -->
  229.         <xsl:when test="toc[.//doc[1]] and @id != 'index'">
  230.           <xsl:call-template name="print.subsections"/>
  231.         </xsl:when>
  232.        <xsl:otherwise>
  233.           <!-- Main page!!! -->
  234.           <div class="leftbar">
  235.             <h2><xsl:value-of select="topic_title"/></h2>
  236.             <xsl:for-each select="topics//doc">
  237.               <xsl:sort order="descending" data-type="number" select="@weight"/>
  238.               <h3><a href="{@href}" title="{@href}"><xsl:value-of select="title"/></a></h3>
  239.             </xsl:for-each>
  240.           </div>
  241.  
  242.           <p><xsl:value-of select="desc1"/></p>
  243.           <h3><xsl:value-of select="common"/></h3>
  244.           <ul>
  245.             <li><a href="ghelp:internet#connecting"><xsl:value-of select="q1"/></a></li>
  246.             <li><a href="ghelp:desktop-effects"><xsl:value-of select="q2"/></a></li>
  247.             <li><a href="ghelp:musicvideophotos#music"><xsl:value-of select="q3"/></a></li>
  248.             <li><a href="ghelp:musicvideophotos#photos"><xsl:value-of select="q4"/></a></li>
  249.             <li><a href="ghelp:keeping-safe#updates"><xsl:value-of select="q5"/></a></li>
  250.  
  251.           </ul>          
  252.           <h3><xsl:value-of select="notfound"/></h3>
  253.           <p><xsl:value-of select="freesupport_pre"/><xsl:text> </xsl:text> <a href="{freesupport_loc}"><xsl:value-of select="freesupport_link"/></a><xsl:text> </xsl:text> <xsl:value-of select="freesupport_after"/></p>
  254.           <p><xsl:value-of select="commercialsupport_pre"/><xsl:text> </xsl:text> <a href="{commercialsupport_loc}"><xsl:value-of select="commercialsupport_link"/></a><xsl:text> </xsl:text> <xsl:value-of select="commercialsupport_after"/></p>
  255.           <h3><xsl:value-of select="how_contribute"/></h3>
  256.           <p><xsl:value-of select="community_pre"/><xsl:text> </xsl:text> <a href="{community_loc}"><xsl:value-of select="community_link"/></a><xsl:text> </xsl:text> <xsl:value-of select="community_after"/></p>        </xsl:otherwise>      </xsl:choose>
  257.    </div>
  258.   </div>
  259. </xsl:template>
  260.  
  261. <xsl:template match="/">
  262.   <xsl:apply-templates select="//toc" />
  263. </xsl:template>
  264.  
  265. </xsl:stylesheet>
  266.